package com.jiedeng.dao;

import com.jiedeng.model.ProjectPerson;
import com.jiedeng.model.SysNamed;
import com.jiedeng.model.SysProjectGPS;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ISysProjectGPSRepository extends JpaRepository<SysProjectGPS, String> {
    @Query(nativeQuery = true, value = "SELECT " +
            " sp.* " +
            " FROM " +
            " t_person tp " +
            " LEFT JOIN t_project_corp tpc ON tp.Corp_ID = tpc.Corp_ID " +
            " LEFT JOIN sys_projectgps sp on  tpc.Project_ID =sp.t_project_id " +
            " WHERE " +
            " tp.Person_ID = ?1 " +
            " and sp.id is not NULL ")
    List<SysProjectGPS> findSysProjectGPSByPerson(Long personId);

    List<SysProjectGPS> findByCaption(String caption);

    @Query(nativeQuery = true, value = "select max(groupNum) FROM sys_projectgps ")
    Long selectMaxGroupNum();
}
